/**
 * Created by Administrator on 2016/10/16.
 */
var express = require("express");
var router = express.Router();
var mysql = require("mysql");
var DateUtil = require('../../lib/utils/DateUtil');
var _ = require("underscore");

var connection = require('../../lib/utils/DbconnectUtil');

/**
 * 查询项目列表
 */
router.get('/', function (req, res, next) {
    var menuSql = 'select t_menu.id menuId, t_menu.name menuName from t_menu';
    connection().query(menuSql, function (error, results) {
        if (error) {
            res.send({code : -1 , message: JSON.stringify(error)});
        } else {
            res.send({code :0 , data : results});
        }
    });
});

router.get('/subMenus', function (req, res, next) {
    var menuSql = 'select t_sub_menu.id menuId, t_sub_menu.name menuName, t_sub_menu.menu parentMenuId  from t_sub_menu';
    connection().query(menuSql, function (error, results) {
        if (error) {
            res.send({code : -1 , message: JSON.stringify(error)});
        } else {
            res.send({code :0 , data : results});
        }
    });
});

module.exports = router;